<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>产生一个 URL</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.http-build-str.html">http_build_str</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="book.hw.html">Hyperwave</a></div>
 <div class="up"><a href="ref.http.html">HTTP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.http-build-url" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">http_build_url</h1>
  <p class="verinfo">(PECL pecl_http &gt;= 0.21.0)</p><p class="refpurpose"><span class="refname">http_build_url</span> &mdash; <span class="dc-title">产生一个 URL</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.http-build-url-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>http_build_url</strong></span>
    ([ <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$url</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$parts</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = HTTP_URL_REPLACE</span></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$new_url</code></span>
  ]]]] )</div>


  <p class="para rdfs-comment">
   产生一个 URL。
  </p>
  <p class="para">
   第二个 URL 的组成部分将根据 flags 参数，合并到第一个 URL。
  </p>

 </div>

 <div class="refsect1 parameters" id="refsect1-function.http-build-url-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">url</code></em></dt>

     <dd>

      <p class="para">
       一个或多个 URL 的组成部分字符串，或类似 <span class="function"><a href="function.parse-url.html" class="function">parse_url()</a></span> 所返回的关联数组。
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">parts</code></em></dt>

     <dd>

      <p class="para">
       和第一个参数一样。
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">flags</code></em></dt>

     <dd>

      <p class="para">
       <a href="http.constants.html#http.constants.url" class="link">HTTP_URL 常量</a>的二进制或运算位掩码；默认是 <strong><code>HTTP_URL_REPLACE</code></strong>。
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">new_url</code></em></dt>

     <dd>

      <p class="para">
       如果设置了，它将被 URL 组成部分所填充，就像 <span class="function"><a href="function.parse-url.html" class="function">parse_url()</a></span> 所返回的那样
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.http-build-url-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回新的 URL， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 


 


 <div class="refsect1 examples" id="refsect1-function.http-build-url-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4283">
    <p><strong>Example #1 <span class="function"><strong>http_build_url()</strong></span> 的一个例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">http_build_url</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://user@www.example.com/pub/index.php?a=b#files"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"scheme"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"ftp"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"host"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"ftp.example.com"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"path"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"files/current/"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"query"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"a=c"<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">HTTP_URL_STRIP_AUTH&nbsp;</span><span style="color: #007700">|&nbsp;</span><span style="color: #0000BB">HTTP_URL_JOIN_PATH&nbsp;</span><span style="color: #007700">|&nbsp;</span><span style="color: #0000BB">HTTP_URL_JOIN_QUERY&nbsp;</span><span style="color: #007700">|&nbsp;</span><span style="color: #0000BB">HTTP_URL_STRIP_FRAGMENT<br /></span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
ftp://ftp.example.com/pub/files/current/?a=c
</pre></div>
    </div>
   </div>
  </p>
 </div>



 <div class="refsect1 seealso" id="refsect1-function.http-build-url-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.parse-url.html" class="function" rel="rdfs-seeAlso">parse_url()</a> - 解析 URL，返回其组成部分</span></li>
    <li class="member"><span class="function"><a href="function.http-build-str.html" class="function" rel="rdfs-seeAlso">http_build_str()</a> - 产生一个查询字符串</span></li>
   </ul>
  </p>
 </div>



</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.http-build-str.html">http_build_str</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="book.hw.html">Hyperwave</a></div>
 <div class="up"><a href="ref.http.html">HTTP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
